<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Canvas</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
    <style>
        html,
        body {
            width: 100%;
        }
        
        #canvas {
            display: block;
            border: 1px solid #000000;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <canvas id="canvas" width="500" height="500">drawing board</canvas>
    <script>
        let ctx = $('#canvas')[0].getContext('2d');
        ctx.fillStyle = 'deepskyblue';
        ctx.strokeStyle = '#000';
        ctx.beginPath();
        ctx.globalAlpha = 0.5;
        let gradient = ctx.createLinearGradient(30, 30, 100, 100);
        gradient.addColorStop(0, 'blue');
        gradient.addColorStop(1, 'deepskyblue');
        ctx.fillStyle = gradient;
        ctx.fillRect(30, 30, 80, 80);
        let radial = ctx.createRadialGradient(250, 250, 35, 250, 250, 70);
        radial.addColorStop(0, 'blue');
        radial.addColorStop(1, 'deepskyblue');
        ctx.fillStyle = radial;
        ctx.fillRect(180, 180, 140, 140);
        // ctx.closePath();
        ctx.stroke();
    </script>
</body>

</html>